package org.neuedu.chapter07_0624.demo02;

public class ProxyStudent extends Student {
    // 被代理对象
    Student student;

    public ProxyStudent(Student student) {
        this.student = student;
    }

    public ProxyStudent() {
    }

    @Override
    public void add() {
        System.out.println("开启事务");
        student.add();
        System.out.println("提交事务");
    }

    public static void main(String[] args) {
        Student student = new Student();
        // 代理对象
        ProxyStudent proxy = new ProxyStudent(student);
        proxy.add();
    }
}
